package org.exercise;

import org.exercise.entity.Student;
import org.exercise.schedule.Schedule;
import org.exercise.schedule.ScheduleManager;
import org.exercise.schedule.ScheduleTask;

import java.time.LocalDateTime;
import java.util.Date;
import java.util.TimerTask;

/**
 * Hello world!
 */
public class App {
    public static void main(String[] args) {

        Schedule schedule = new ScheduleManager("定时任务管理器");
        TimerTask printTimeTask = new ScheduleTask(() -> System.out.println(LocalDateTime.now()), "打印系统当前时间", 5);
        TimerTask printStuInfoTask = new ScheduleTask(
                () -> System.out.println(new Student(1, "张三", "一班", "CQUT")), "打印学生信息", 5);

        schedule.scheduleAtFixedRate(printStuInfoTask, new Date(), 2 * 1000);
        schedule.scheduleAtFixedRate(printTimeTask, new Date(), 3 * 1000);
        schedule.stop();

    }
}
